import tool
from pygame.locals import *
from jiong import *

class Ghost(Jiong):
    
    # pos (x, y): > 0
    # speed(dx, dy) : not none
    def __init__(self, pos, speed, distance):
        Jiong.__init__(self, tool.load_image('ghost.bmp', (0, 0, 0)), pos)
        self.__speed = list(speed)
        self.__distance = distance
        self.__moved = [0, 0]
    
    def update(self):
        if self.__moved[0] > self.__distance[0] \
        or self.__moved[1] > self.__distance[1]:
            self.__speed = [-self.__speed[0], -self.__speed[1]]
            self.__moved = [0, 0]
        coll = self.move(self.__speed)
        if len(coll) == 0:
            self.__moved[0] += abs(self.__speed[0])
            self.__moved[1] += abs(self.__speed[1])
        Jiong.update(self)
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        